package com.esms.struts.service;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.esms.bean.Group;
import com.esms.bean.GroupDAO;
import com.esms.bean.Person;
import com.esms.bean.PersonDAO;

public class AccessGroupService {
	private AccessGroupService() {}
	public static AccessGroupService $ = new AccessGroupService(); 
	
	public List getGroups() {
		List entityList = GroupDAO.$.findAll();
		List nameList = new ArrayList();
		for(Iterator it = entityList.iterator(); it.hasNext();) {
			Group group = (Group) it.next();
			nameList.add(group.getGroupname());
		}
		return nameList;
	}
	
	public int getGroupId(String groupType) {
		List entityList = GroupDAO.$.findByGroupname(groupType);
		if(entityList.size() == 0)
			return 0;
		else {
			Group group = (Group) entityList.get(0);
			return group.getGroupid();
		}
	}
}
